package LibraryManagementSystem.impl;

import LibraryManagementSystem.IOperation;
import LibraryManagementSystem.book.Book;
import LibraryManagementSystem.book.Bookcase;

/**
 * @author : niu niu
 * @version : 1.0.0
 * @date : 2022/10/21 17:31
 * 添加操作
 */
public class AddOperation implements IOperation {

    @Override
    public void work(Bookcase bookcase) {
        System.out.println("您现在进行添加书籍操作 ");
        System.out.println("请输入书籍名称:");
        String bookName = scanner.next();
        if (bookcase.isBookContains(bookName)){
            System.out.println("该书已存在，无需重复添加！");
        }
        System.out.println("请输入书籍价格:");
        double price = scanner.nextDouble();
        System.out.println("请输入作者姓名:");
        String author = scanner.next();
        System.out.println("请输入类型:");
        String type = scanner.next();

        Book book = new Book(bookName,author,price,type);
        bookcase.addBook(book);
        System.out.println("书籍添加成功！");
    }
}
